﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace OpenCvApplication.View.CommonView
{
    [Serializable]
    [ComVisible(true)]
    [TypeConverter(typeof(ShadowParameterConverter))]
    public class ShadowParameter
    {
        private int _shadowsStartAlpha = 255;
        [DefaultValue(255), Category("EasyUI"), Description("阴影起始透明度")]
        public int ShadowsStartAlpha
        {
            get { return _shadowsStartAlpha; }
            set
            {
                if (value >= 0 && value <= 255)
                    _shadowsStartAlpha = value;
            }
        }
        private Color _shadowStartColor = Color.Black;
        [DefaultValue(typeof(Color)), Category("EasyUI"), Description("阴影起始颜色")]
        public Color ShadowStartColor
        {
            get
            {
                return _shadowStartColor;
            }
            set
            {
                _shadowStartColor = value;
                ShadowEndColor = value;
            }
        }
        private int _shadowsEndAlpha = 0;
        [DefaultValue(0), Category("EasyUI"), Description("阴影结束透明度")]
        public int ShadowsEndAlpha
        {
            get { return _shadowsEndAlpha; }
            set
            {
                if (value >= 0 && value <= 255)
                    _shadowsEndAlpha = value;
            }
        }
        private Color _shadowEndColor = Color.Black;
        [DefaultValue(typeof(Color)), Category("EasyUI"), Description("阴影结束颜色")]
        public Color ShadowEndColor
        {
            get
            {
                return _shadowEndColor;
            }
            set
            {
                _shadowEndColor = value;
            }
        }

        private Point _shadowOffset = new Point(0, 0);
        [DefaultValue(typeof(Point)), Category("EasyUI"), Description("阴影偏移")]
        public Point ShadowOffset
        {
            get { return _shadowOffset; }
            set
            {
                _shadowOffset = value;
            }
        }
        private Size _shadowSize = new Size(4, 4);
        [DefaultValue(10), Category("EasyUI"), Description("阴影大小")]
        public Size ShadowSize
        {
            get { return _shadowSize; }
            set
            {
                _shadowSize = value;
            }
        }
    }
    public class ShadowParameterConverter : TypeConverter
    {
        public override bool GetPropertiesSupported(ITypeDescriptorContext context)
        {
            return true;
        }

        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
        {
            return TypeDescriptor.GetProperties(typeof(ShadowParameter));
        }
    }
}
